﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataLib.Accounts.Bus;
using DataLib.Common;
using System.Data;

namespace Ewts.Cumtomer
{
    public partial class LoadSearch : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                bindData();
            }
        }
        protected void bindData( )
        {
            if (Session["UserInfo"] != null)
            {
                User curUser = new DataLib.Accounts.Bus.User();
                curUser = (User)Session["UserInfo"];
      
                DataTable dtBar = new DataTable();
                DataTable dtTotal = new DataTable();
 
                string cum = "" ;
                string time1 = txtStart.Value;
                string teim2 = txtEnd.Value;
                string load = txtLoad.Value.Trim();

                if (curUser.UserType == "CC") 
                {
                    cum = new DataLib.BLL.cum_aacounts().GetCumByUserid(curUser.UserID).customercode;
                    dtBar = new DataLib.BLL.LTR_CJO().GetList(" customercode='" + cum + "'").Tables[0];
                    dtBar = GetLoadItem(cum);
                }
                //if (curUser.UserType == "CA" || curUser.UserType == "CB" || curUser.UserType == "CC")
                //{
                //    dtBar = new DataLib.BLL.Tally().GetTallyProc(load,cum, "","","","",time1, teim2, "", "");
                //}
                    //dtBar = GetLoadItem(cum);
                reptBar.DataSource = dtBar;
                reptBar.DataBind();
                reptTotal.DataSource = new DataLib.BLL.InStorage().GetTotal(dtBar);
                reptTotal.DataBind();
                
            }
        }

        public DataTable GetLoadItem(string cum)
        {
            DataTable dt = new DataTable();
            string loadnum = txtLoad.Value.Trim();
            string dtime1 = txtStart.Value.Trim();      //收集日期起
            string dtime2 = txtEnd.Value.Trim();      //收集日期止
            //string goodsName = txtGoodsName.Value.Trim();   //物品名称
            //string barstatus = dropCurStatus.SelectedValue;    //已处理2 未处理1
            //dt = new DataLib.BLL.InStorage().GETWRLItem(loadnum, cum, dtime1, dtime2, goodsName, barstatus);
            return dt;
        }

 

        ////取得当前状态的中文描述  by 2013.03.27 梁玲
        //public string GetStatus(string status, string loadno)
        //{
        //    string statusname = "";
        //    switch (status)
        //    {
        //        case "1":
        //            statusname = "未收集";
        //            break;
        //        case "2":
        //            statusname = "收集中";
        //            break;
        //        case "3":
        //            statusname = "已收到";
        //            break;
        //        case "4":
        //            statusname = "处理中";
        //            break;
        //        default:
        //            DataTable dt = new DataLib.BLL.FinaceData().GetList(" LoadNumNo='" + loadno + "'").Tables[0];
        //            if (dt.Rows.Count > 0 && dt != null)
        //            {
        //                statusname = "已结算";
        //            }
        //            else
        //            {
        //                DataTable dt1 = new DataLib.BLL.Tally().GetList(" LoadNo='" + loadno + "'").Tables[0];
        //                if (dt1.Rows.Count > 0 && dt1 != null)
        //                {
        //                    statusname = "已处理";
        //                }
        //            }
        //            break;
        //    }
        //    return statusname;

        //}

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            bindData();
        }


      
    }
}